package com.base.controller;

import com.base.po.coupon_prestore.CouponBrandPrestore;
import com.base.service.COUPON.CouponBrandPrestoreService;
import com.base.service.LogsService;
import com.base.utils.Produce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 添加365优惠券品牌信息服务端
 * 
 * @author K
 *
 */
@Controller
@RequestMapping("/admin")
public class add_CouponBrandPrestore {

	@Autowired
	private LogsService logsService; // log日志
	@Autowired
	private CouponBrandPrestoreService couponBrandPrestoreService; // 商品品牌信息

	// 添加品牌信息
	@RequestMapping(value = "/toAddCouponBrandPrestore", method = RequestMethod.POST)
	public @ResponseBody int toAddCouponBrandPrestore(HttpServletRequest request, @RequestBody CouponBrandPrestore couponBrandPrestore) throws Exception {
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
		if (userid == null) return -1; // 未登录
		couponBrandPrestore.setId(Produce.getUUID()); // 设置参数 主键ID
		couponBrandPrestore.setParentid(userid); // 代理商ID
		couponBrandPrestore.setDatastatus((byte) 1); // 数据状态
		return couponBrandPrestoreService.insertSelective(couponBrandPrestore); // 添加
	}
}
